package com.zhijian.warehouse.manage.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import java.util.concurrent.Executor;

@Component
public class ThreadPoolHelper {

    private static Executor staticExecutor;

    @Autowired
    @Qualifier("taskExecutor")
    public void setExecutor(Executor executor){
        ThreadPoolHelper.staticExecutor = executor;
    }

    public static void createThreadAndRun(Runnable runnable){
        staticExecutor.execute(runnable);
    }
}
